<%--
  Created by IntelliJ IDEA.
  User: wen
  Date: 2018/7/8
  Time: 11:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>

    <title>用户信息页面 </title>


    <script type="text/javascript" src="/js/jquery-2.1.3.min.js"></script>
    <script type="text/javascript">

        $(document).ready(function(){
            $.ajax({
                type:"POST",
                url: "/user/getUserInfo.do",

                success: function(data){
                    if(data.status == 0){

                        $("#user-name-label").text(data.data.username);
                        $("#username").text(data.data.username);
                        $("#password").text(data.data.password);
                        $("#phone").text(data.data.phone);
                        $("#question").text(data.data.question);
                        $("#answer").text(data.data.answer);
                       /* $("#role").text(data.data.role);*/
                        // window.location.href = "/view/java.jsp";
                        if(data.data.role == 1){
                            $("#role").text("管理员");
                            $("#add").html( "<input  type='submit' onclick='addJava()' value='添加试题'></input>");
                        }else {
                            $("#role").text("普通用户");
                        }

                    }else {
                        alert(data.msg);
                    }
                }
            });

        });

        function begin() {
            window.location.href = "/view/java.jsp";

        }
        function logout() {
            window.location.href = "/index.jsp";

        }
        function addJava() {
            window.location.href = "/view/addJava.jsp";

        }

    </script>


</head>
<body>
<div>
    <h1>欢迎：<span id="user-name-label"></span></h1>
    用户名:<span id="username"></span><br>
    密码:<span id="password"></span><br>
    电话:<span id="phone"></span><br>
    忘记密码问题:<span id="question"></span><br>
    问题答案:<span id="answer"></span><br>
    权限:<span id="role"></span><br>

    <input type="submit" onclick="begin()"  value="开始练题">
    <%--<input type="submit" onclick="begin()" value="开始练题">--%>
    <input type="submit" onclick="logout()" value="退出登录">
    <span id="add"></span>

</div>



</body>
</html>
